package com.aaa.whj.service.impl;

import com.aaa.whj.dao.IProblemDao;
import com.aaa.whj.entity.TabProblem;
import com.aaa.whj.entity.Tab_scl_record;
import com.aaa.whj.service.IProblemService;
import com.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class ProblemServiceImpl implements IProblemService {
    SqlSession session= SqlSessionFactoryUtil.getSession();
    IProblemDao iProblem=session.getMapper(IProblemDao.class);

    @Override
    public List<TabProblem> queryAll() {
        return this.iProblem.queryAll();
    }

    @Override
    public int updateProblem(String data) {
        int num=0;
        IndexServiceImpl indexService=new IndexServiceImpl();
        Tab_scl_record record = indexService.record(data);
        if(record.getF1()>2.43){
            int i = this.iProblem.updateProblem(1);
            num=num+i;
        }
        if(record.getF2()>3.27){
            int i = this.iProblem.updateProblem(2);
            num=num+i;
        }
        if(record.getF3()>3.46){
            int i = this.iProblem.updateProblem(3);
            num=num+i;
        }
        if(record.getF4()>3.13){
            int i = this.iProblem.updateProblem(4);
            num=num+i;
        }
        if(record.getF5()>2.82){
            int i = this.iProblem.updateProblem(5);
            num=num+i;
        }
        if(record.getF6()>3.13){
            int i = this.iProblem.updateProblem(6);
            num=num+i;
        }
        if(record.getF7()>2.52){
            int i = this.iProblem.updateProblem(7);
            num=num+i;
        }
        if(record.getF8()>3.23){
            int i = this.iProblem.updateProblem(8);
            num=num+i;
        }
        if(record.getF9()>2.17){
            int i = this.iProblem.updateProblem(9);
            num=num+i;
        }
        if(record.getF10()>2.33){
            int i = this.iProblem.updateProblem(10);
            num=num+i;
        }
        return num;
    }
}
